<template>
	<!-- 帮助中心 -->
	<view class="help-center">
		<nav-bar :title="i18n.home.help" @_back="_back" />
		<view class="container">
			<view class="help-box" v-for="item in list" :key="item.id" @click="jump(item.id)">
				<view class="white-text">
					<text>{{item.title}}</text>
				</view>
				<u-icon name="arrow-right" color="rgba(255, 255, 255, .4)" size="24"></u-icon>
			</view>
		</view>
		<u-empty v-if="isEmpty && !list.length" :text="i18n.common.noHistory" mode="history"></u-empty>
		<custom-loading text="" mask="true" click="true" ref="loading"></custom-loading>
	</view>
</template>

<script>
	import minix from '@/utils/minix.js'
	import {
		newsHelp
	} from '@/api/index.js'
	import CustomLoading from '@/components/Loadidng/index.vue'
	export default {
		mixins: [minix],
		data() {
			return {
				list: [],
				isEmpty: false
			}
		},
		components: {
			CustomLoading
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
		},
		mounted() {
			this.loadList()
			this.$refs.loading.open();
		},
		methods: {
			jump(id) {
				uni.navigateTo({
					url: '/pages/help/detail?id=' + id
				})
			},
			async loadList() {
				let {
					error,
					res
				} = await newsHelp({
					c_id: 3
				});
				this.$refs.loading.close();
				if (error) return;
				this.isEmpty = true;
				this.list = res.list || [];
			},
			_back() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.help-center {
		.container {
			margin-top: 30rpx;

			.help-box {
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid rgba(255, 255, 255, .1);
				font-weight: bold;
				font-size: 32rpx;

				.white-text {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}
	}
</style>
